using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MySql.Data.MySqlClient;
using System.Data;
using System.Configuration;

namespace TestProject
{
	
	[HandleError]
	public class UserController : Controller
	{
		
		
		
		public ActionResult Index (String u_name, String p_word)
		{
		//	User read  = User.User(u_name, p_word);
			
			User read = new User(u_name, p_word);
				
			if(u_name.Equals(read.username))
			{
				
				Session.Add("username", read.username);
				Session.Add("level", read.level);
				Session.Add("fname", read.firstname);
				Session.Add("lname", read.lastname);
				Session.Add("email", read.email);
				Session.Add("user_id", read.user_ID);
				
				if(read.level == 1) return View (TempData);	
				else 
				{
					return RedirectToAction ("../Librarian");
				}
			}
			else
			{
				return RedirectToAction ("../Home/error");
				
			}
			//ViewData["_user"] = read;
			//return View (ViewData);
		}
				
			
				
		public ActionResult Login ()
		{
			return View ("User/index");
			
		}	
		
		public ActionResult Logout ()
		{
			Session.Abandon();
			
			return RedirectToAction ("../Home");
		}
		
		public void AddUser(string username, string pass, string fname, string lname, string email)
		{
			
		}
			
				
			
			
		}
			
}


